package com.quanyan.stadium.service.commonComponent.impl;

import com.google.gson.Gson;
import com.quanyan.club.entity.RespClubXpLevelMsg;
import com.quanyan.club.mq.ClubMedalMsg;
import com.quanyan.comment.enums.TaskEnum;
import com.quanyan.common.constants.Constants;
import com.quanyan.common.constants.MqConstants;
import com.quanyan.common.enums.SysClubMedalConditionEnum;
import com.quanyan.common.enums.SysUserMedalConditionEnum;
import com.quanyan.common.utils.ObjectUtil;
import com.quanyan.mq.client.QcMsgClient;
import com.quanyan.mq.client.reqeust.MqRequestMsg;
import com.quanyan.stadium.api.req.ReqRecordGameScheduleResult;
import com.quanyan.stadium.constants.GameConstants;
import com.quanyan.stadium.entity.TbGameEvent;
import com.quanyan.stadium.entity.TbGameMqMsgLog;
import com.quanyan.stadium.entity.TbGameRound;
import com.quanyan.stadium.entity.TbGameSchedule;
import com.quanyan.stadium.entity.vo.StadiumNotifyMsg;
import com.quanyan.stadium.enums.StadiumMsgEnum;
import com.quanyan.stadium.service.commonComponent.GameMQLog;
import com.quanyan.stadium.service.commonComponent.GameMQProduct;
import com.quanyan.stadium.utils.IDGenerationStrategiesUtils;
import com.quanyan.user.mq.UserMedalMsg;
import com.quanyan.user.mq.UserTaskMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xiaoxiao
 * @date 16/4/11-14:42
 *
 * 运动场,赛事相关的消息推送
 */

@Service("gameMQProduct")
public class GameMQProductImpl implements GameMQProduct {

    private final static Logger logger = LoggerFactory.getLogger(GameMQProductImpl.class);

    @Autowired
    private QcMsgClient qcMsgClient;

    @Autowired
    private GameMQLog gameMQLog;


    @Override
    public void userRecordScoreMQ(ReqRecordGameScheduleResult req, Integer uid){
        logger.info("用户录入比分,当前赛程ID:{}", req.getGameScheduleId());
        UserTaskMsg userTaskMsg = new UserTaskMsg();
        userTaskMsg.setTaskId(TaskEnum.TASK_ENUM__JL_SG.getId());
        userTaskMsg.setUid(uid);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(Constants.MQ_TOPIC_TASK_TOPIC);
        mqRequestMsg.setTag(Constants.MQ_TOPIC_TASK_TAG);
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        mqRequestMsg.setMsgId(msgId); //msgId号.
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(userTaskMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(userTaskMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(req.getGameEventId());
        tbGameMqMsgLog.setGameGroundId(req.getGameRoundId());
        tbGameMqMsgLog.setGameScheduleId(req.getGameScheduleId());
        tbGameMqMsgLog.setMsgName("");
        tbGameMqMsgLog.setMsgTag(Constants.MQ_TOPIC_TASK_TAG);
        tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //评级积分
        logger.info("发送消息，msgId：{} ", mqRequestMsg.getMsgId());
    }

    @Override
    public void gameScheduleWinUserMQ(List<Integer> uids, TbGameEvent tbGameEvent, TbGameRound tbGameRound) {
        List<UserTaskMsg> userTaskMsgs = new ArrayList<>();
        if (null!=uids && uids.size() >0) {
            for (Integer temp : uids) {
                UserTaskMsg userTaskMsg = new UserTaskMsg();
                userTaskMsg.setTaskId(TaskEnum.TASK_ENUM__GAME_WIND.getId());
                userTaskMsg.setUid(temp);
                userTaskMsgs.add(userTaskMsg);
            }
            String msgId = IDGenerationStrategiesUtils.getMsgId();
            MqRequestMsg mqRequestMsg = new MqRequestMsg();
            mqRequestMsg.setTopic(Constants.MQ_TOPIC_TASK_ACTIVITY_TOPIC);
            mqRequestMsg.setTag(Constants.MQ_TOPIC_TASK_ACTIVITY_TAG);
            mqRequestMsg.setMsgId(msgId); //msgId号.
            mqRequestMsg.setFlag(0);
            mqRequestMsg.setBody(ObjectUtil.toByteArray(userTaskMsgs));

            Gson gson = new Gson();
            TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
            tbGameMqMsgLog.setMsgBody(gson.toJson(userTaskMsgs));
            tbGameMqMsgLog.setGameMsgNo(msgId);
            tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
            tbGameMqMsgLog.setGameGroundId(tbGameRound.getId());
            tbGameMqMsgLog.setMsgName("");
            tbGameMqMsgLog.setMsgTag(Constants.MQ_TOPIC_TASK_ACTIVITY_TAG);
            tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
            gameMQLog.initMQLog(tbGameMqMsgLog);

            qcMsgClient.asyncSend(mqRequestMsg);   //用户录入积分录入奖励
            logger.info("每一轮官方赛程完结记录用户输赢结果,发动给任务中心,当前赛事:{},当前赛事:{},", tbGameEvent.getId(), tbGameRound.getId());
        }
    }

    @Override
    public void clubCreateGameToUserCenterMQ(TbGameEvent tbGameEvent, Integer uid) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        UserTaskMsg userTaskMsg = new UserTaskMsg();
        userTaskMsg.setUid(uid);
        userTaskMsg.setTaskId(TaskEnum.TASK_ENUM__GF_CGS.getId());
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(Constants.MQ_TOPIC_TASK_TOPIC);
        mqRequestMsg.setTag(msgId);
        mqRequestMsg.setMsgId(IDGenerationStrategiesUtils.getMsgId()); //msgId号.
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(userTaskMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(userTaskMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName("");
        tbGameMqMsgLog.setMsgTag(TaskEnum.TASK_ENUM__GF_CGS.getId()+"");
        tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //俱乐部用户发布积分赛,消息通知
        logger.info("俱乐部个人创建赛事消息，msgId：{} ", mqRequestMsg.getMsgId());
    }

    @Override
    public void clubCreateGameToClubMQ(TbGameEvent tbGameEvent, Integer uid, Integer clubId) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        RespClubXpLevelMsg clubLevelMsg = new RespClubXpLevelMsg();
        clubLevelMsg.setUid(uid);
        clubLevelMsg.setExpName("CREATE_EVENT");
        clubLevelMsg.setClubId(clubId);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(MqConstants.CLUB_XP_LEVEL_TOPIC_NAME);
        mqRequestMsg.setTag(MqConstants.CLUB_XP_LEVEL_TAGS_NAME);
        mqRequestMsg.setMsgId(IDGenerationStrategiesUtils.getMsgId()); //msgId号.
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(clubLevelMsg));
        qcMsgClient.asyncSend(mqRequestMsg);

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(clubLevelMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName("");
        tbGameMqMsgLog.setMsgTag(MqConstants.CLUB_XP_LEVEL_TAGS_NAME);
        tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
        gameMQLog.initMQLog(tbGameMqMsgLog);


        logger.info("俱乐部创建赛事,增加等级, 发送MQ，msgId：{} ", mqRequestMsg.getMsgId());
    }


    @Override
    public void gameScheduleWinUserMedalMQ(Integer categoryId, List<Integer> uids) {
        if (null!=uids && uids.size()>0) {
            Integer mId = 0;
            if (categoryId.intValue() == GameConstants.CATEGORY_ID_FOOTBALL) {
                mId = SysUserMedalConditionEnum.FOOTBALL_MAGNATE.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_BASKETBALL) {
                mId = SysUserMedalConditionEnum.BASKETBALL_MAGNATE.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_TENNIS) {
                mId = SysUserMedalConditionEnum.TENNIS_MAGNATE.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_BADMINTON) {
                mId = SysUserMedalConditionEnum.FOOTBALL_MAGNATE.getId();
            }
            List<UserMedalMsg> result = new ArrayList<>();
            for (Integer temp : uids) {
                UserMedalMsg userMedalMsg = new UserMedalMsg();
                userMedalMsg.setUid(temp);
                userMedalMsg.setCategoryId(temp);
                userMedalMsg.setMedalId(mId);
                result.add(userMedalMsg);
            }
            String msgId = IDGenerationStrategiesUtils.getMsgId();
            MqRequestMsg mqRequestMsg = new MqRequestMsg();
            mqRequestMsg.setTopic(MqConstants.UserMedalConsumer.USERE_MEDAL_TOPIC);
            mqRequestMsg.setTag(MqConstants.UserMedalConsumer.USER_MEDAL_TAGS);
            mqRequestMsg.setMsgId(msgId); //msgId号.
            mqRequestMsg.setFlag(0);
            mqRequestMsg.setBody(ObjectUtil.toByteArray(result));


            Gson gson = new Gson();
            TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
            tbGameMqMsgLog.setMsgBody(gson.toJson(result));
            tbGameMqMsgLog.setGameMsgNo(msgId);
            tbGameMqMsgLog.setMsgName("");
            tbGameMqMsgLog.setMsgTag(MqConstants.UserMedalConsumer.USER_MEDAL_TAGS);
            tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
            gameMQLog.initMQLog(tbGameMqMsgLog);

            qcMsgClient.asyncSend(mqRequestMsg);
            logger.info("发送用户中心[勋章]消息，msgId：{} ", mqRequestMsg.getMsgId());
        }
    }

    @Override
    public void gameScheduleWinClubMedalMQ(Integer categoryId, List<Integer> clubIds) {
        if (null!=clubIds && clubIds.size()>0) {
            Integer mId = 0;
            if (categoryId.intValue() == GameConstants.CATEGORY_ID_FOOTBALL) {
                mId = SysClubMedalConditionEnum.FOOTBALL_STAR.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_BASKETBALL) {
                mId = SysClubMedalConditionEnum.BASKETBALL_STAR.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_TENNIS) {
                mId = SysClubMedalConditionEnum.TENNIS_STAR.getId();
            }else if (categoryId.intValue() == GameConstants.CATEGORY_ID_BADMINTON) {
                mId = SysClubMedalConditionEnum.BADMINTON_STAR.getId();
            }
            List<ClubMedalMsg> result = new ArrayList<>();
            for (Integer temp : clubIds) {
                ClubMedalMsg clubMsg = new ClubMedalMsg();
                clubMsg.setCategoryId(categoryId);
                clubMsg.setClubId(temp);
                clubMsg.setMedalId(mId);
                result.add(clubMsg);
            }
            String msgId = IDGenerationStrategiesUtils.getMsgId();
            MqRequestMsg mqRequestMsg = new MqRequestMsg();
            mqRequestMsg.setTopic(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TOPIC);
            mqRequestMsg.setTag(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TAGS);
            mqRequestMsg.setMsgId(msgId); //msgId号.
            mqRequestMsg.setFlag(0);
            mqRequestMsg.setBody(ObjectUtil.toByteArray(result));


            Gson gson = new Gson();
            TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
            tbGameMqMsgLog.setMsgBody(gson.toJson(result));
            tbGameMqMsgLog.setGameMsgNo(msgId);
            tbGameMqMsgLog.setMsgName("");
            tbGameMqMsgLog.setMsgTag(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TAGS);
            tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
            gameMQLog.initMQLog(tbGameMqMsgLog);


            qcMsgClient.asyncSend(mqRequestMsg);
            logger.info("发送俱乐部[勋章]消息，msgId：{} ", mqRequestMsg.getMsgId());
        }
    }

    @Override
    public void clubJoinOfficialGameNumClubMedalMQ(Integer categoryId, List<Integer> clubIds) {
        if (null!=clubIds && clubIds.size()>0) {
            Integer mId = SysClubMedalConditionEnum.EXCELLENCE.getId();
            List<ClubMedalMsg> result = new ArrayList<>();
            for (Integer temp : clubIds) {
                ClubMedalMsg clubMsg = new ClubMedalMsg();
                clubMsg.setCategoryId(categoryId);
                clubMsg.setClubId(temp);
                clubMsg.setMedalId(mId);
            }
            String msgId = IDGenerationStrategiesUtils.getMsgId();
            MqRequestMsg mqRequestMsg = new MqRequestMsg();
            mqRequestMsg.setTopic(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TOPIC);
            mqRequestMsg.setTag(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TAGS);
            mqRequestMsg.setMsgId(msgId); //msgId号.
            mqRequestMsg.setFlag(0);
            mqRequestMsg.setBody(ObjectUtil.toByteArray(result));

            Gson gson = new Gson();
            TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
            tbGameMqMsgLog.setMsgBody(gson.toJson(result));
            tbGameMqMsgLog.setGameMsgNo(msgId);
            tbGameMqMsgLog.setMsgName("");
            tbGameMqMsgLog.setMsgTag(MqConstants.ClubMedalConsumer.CLUB_MEDAL_TAGS);
            tbGameMqMsgLog.setMsgScope(GameConstants.IS_DELETE.byteValue());
            gameMQLog.initMQLog(tbGameMqMsgLog);

            qcMsgClient.asyncSend(mqRequestMsg);
            logger.info("发送俱乐部[勋章]消息，msgId：{} ", mqRequestMsg.getMsgId());
        }
    }

    /******************内部******************/

    @Override
    public void userScheduleInitMQ(TbGameEvent tbGameEvent, TbGameRound currentTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_USER_SCHEDULE_INIT_SCHEDULE);
        stadiumNotifyMsg.setCurrentGameRound(currentTbGameRound);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(currentTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_INIT_SCHEDULE.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_INIT_SCHEDULE.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_INIT_SCHEDULE.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //用户赛程表初始化
        logger.info("MQ消息发送:初始化用户赛程信息，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, msgId：{} ", tbGameEvent.getId(), currentTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void userScheduleUpdateMQ(TbGameSchedule tbGameSchedule, TbGameRound tbGameRound){
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_USER_SCHEDULE_UPDATE_SCHEDULE);
        stadiumNotifyMsg.setTbGameSchedule(tbGameSchedule);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameGroundId(tbGameRound.getId());
        tbGameMqMsgLog.setGameScheduleId(tbGameSchedule.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_UPDATE_SCHEDULE.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_UPDATE_SCHEDULE.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_UPDATE_SCHEDULE.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //用户赛程表赛程信息更新
        logger.info("MQ消息发送:更新当前赛程信息，当前轮次gameRoundId:{}, 当前赛程gameScheduleId:{}, msgId：{} ", tbGameRound.getId(), tbGameSchedule.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void userScheduleFinishMQ(TbGameEvent tbGameEvent, TbGameRound preTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();

        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setCurrentGameRound(preTbGameRound);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_USER_SCHEDULE_FINALLY_SCHEDULE);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(preTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_FINALLY_SCHEDULE.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_FINALLY_SCHEDULE.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_USER_SCHEDULE_FINALLY_SCHEDULE.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //最终更新用户表的积分信息
        logger.info("MQ消息发送:最终更新用户赛程表信息，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, 消息msgId:{} ", tbGameEvent.getId(), preTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameScheduleEndScoreGradeMQ(TbGameEvent tbGameEvent, TbGameRound preTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setCurrentGameRound(preTbGameRound);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_SCORE_GRADE);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND); //积分通知.
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setMsgId(msgId); //msgId号.
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(preTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_SCORE_GRADE.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_SCORE_GRADE.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_SCORE_GRADE.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //评级积分
        logger.info("MQ消息发送:某一轮次结束开始更新用户评级积分，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, 消息msgId:{} ", tbGameEvent.getId(), preTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameScheduleEndRadarChartMQ(TbGameEvent tbGameEvent, TbGameRound preTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setCurrentGameRound(preTbGameRound);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_RADAR_CHART);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(preTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_RADAR_CHART.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_RADAR_CHART.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_RADAR_CHART.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //更新用户的雷达图
        logger.info("MQ消息发送:某一轮次结束开始更新用户雷达图，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, msgId：{} ", tbGameEvent.getId(), preTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameScheduleEndRemindPushMsgMQ(TbGameEvent tbGameEvent, TbGameRound preTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setCurrentGameRound(preTbGameRound);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_SCHEDULE_END_PUSH_MSG);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(preTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_SCHEDULE_END_PUSH_MSG.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_SCHEDULE_END_PUSH_MSG.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_SCHEDULE_END_PUSH_MSG.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //调起推送消息
        logger.info("MQ消息发送:某一轮次结束开始发送轮次结束信息,以便调起一些推送服务，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, msgId：{} ", tbGameEvent.getId(), preTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameEventFinish(TbGameEvent tbGameEvent, TbGameRound curTbGameRound) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setCurrentGameRound(curTbGameRound);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_EVENT_FINISH_INIT_GAME_SCORE);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));

        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setGameGroundId(curTbGameRound.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_INIT_GAME_SCORE.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_INIT_GAME_SCORE.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_INIT_GAME_SCORE.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);

        qcMsgClient.asyncSend(mqRequestMsg);   //调起推送消息
        logger.info("MQ消息发送:赛事结束发起，当前赛事gameEventId:{}, 当前轮次gameRoundId:{}, msgId：{} ", tbGameEvent.getId(), curTbGameRound.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameEventFinishStartPushMsgMQ(TbGameEvent tbGameEvent) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_EVENT_FINISH_PUSH_MSG);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_PUSH_MSG.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_PUSH_MSG.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_PUSH_MSG.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //栏目积分
        logger.info("MQ消息发送:官方赛事结束,初始化积分完毕,开始计算推送相关信息，当前赛事gameEventId:{}, msgId：{} ", tbGameEvent.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameEventFinishStartCollectMsgMQ(TbGameEvent tbGameEvent) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_EVENT_FINISH_MSG_COLLECT);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_MSG_COLLECT.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_MSG_COLLECT.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_MSG_COLLECT.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //栏目积分
        logger.info("MQ消息发送:官方赛事结束,初始化积分完毕,开始进行数据汇总，当前赛事gameEventId:{}, msgId：{} ", tbGameEvent.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameEventFinishCumsumScoreMQ(TbGameEvent tbGameEvent) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_GAME_EVENT_FINISH_JOIN_INTO_MONTH);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_JOIN_INTO_MONTH.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_JOIN_INTO_MONTH.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_GAME_EVENT_FINISH_JOIN_INTO_MONTH.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //栏目积分
        logger.info("MQ消息发送:官方赛事结束,初始化积分完毕,积分累加，当前赛事gameEventId:{}, msgId：{} ", tbGameEvent.getId(), mqRequestMsg.getMsgId());
    }

    @Override
    public void gameEventFinishScoreCategoryMQ(TbGameEvent tbGameEvent) {
        String msgId = IDGenerationStrategiesUtils.getMsgId();
        StadiumNotifyMsg stadiumNotifyMsg = new StadiumNotifyMsg();
        stadiumNotifyMsg.setTbGameEvent(tbGameEvent);
        stadiumNotifyMsg.setMsgType(GameConstants.STADIUM_TAG_ROUND_RECORD);
        MqRequestMsg mqRequestMsg = new MqRequestMsg();
        mqRequestMsg.setTopic(GameConstants.STADIUM_TOPIC_ROUND);
        mqRequestMsg.setTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        mqRequestMsg.setFlag(0);
        mqRequestMsg.setMsgId(msgId);
        mqRequestMsg.setBody(ObjectUtil.toByteArray(stadiumNotifyMsg));


        Gson gson = new Gson();
        TbGameMqMsgLog tbGameMqMsgLog = new TbGameMqMsgLog();
        tbGameMqMsgLog.setMsgBody(gson.toJson(stadiumNotifyMsg));
        tbGameMqMsgLog.setGameMsgNo(msgId);
        tbGameMqMsgLog.setGameEventId(tbGameEvent.getId());
        tbGameMqMsgLog.setMsgName(StadiumMsgEnum.STADIUM_TAG_ROUND_RECORD.getCode());
        tbGameMqMsgLog.setMsgDesc(StadiumMsgEnum.STADIUM_TAG_ROUND_RECORD.getName());
        tbGameMqMsgLog.setNotifyMethod(StadiumMsgEnum.STADIUM_TAG_ROUND_RECORD.getLabel());
        tbGameMqMsgLog.setMsgTag(GameConstants.STADIUM_TOPIC_ROUND_RECORD);
        gameMQLog.initMQLog(tbGameMqMsgLog);


        qcMsgClient.asyncSend(mqRequestMsg);   //栏目积分
        logger.info("MQ消息发送:赛事更新用户栏目积分，当前赛事gameEventId:{}, msgId：{} ", tbGameEvent.getId(), mqRequestMsg.getMsgId());
    }

}